package org.example.greenhouse.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.example.greenhouse.entity.GreenHouse;
import org.example.greenhouse.result.Result;
import org.example.greenhouse.service.GreenHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@CrossOrigin
@RestController
@Api(tags = "大棚")
@RequestMapping("/Greenhouse")
public class GreenHouseController {

    @Autowired
    private GreenHouseService greenHouseService;

    @ApiOperation("添加大棚")
    @PostMapping("/addGreenHouse")
    public Result addGreenHouse(@RequestBody GreenHouse greenHouse) {
        return greenHouseService.addGreenHouse(greenHouse);
    }

    @ApiOperation("获取大棚信息")
    @GetMapping("/getInfoById")
    public Result getGreenHouseById(@RequestParam Long houseId) {
        return greenHouseService.getGreenHouseById(houseId);
    }

    @ApiOperation("获取所有大棚数据")
    @GetMapping("/getInfoAll")
    public Result getAllGreenHouses() {
        return greenHouseService.getAllGreenHouses();
    }


}